<ul class="gridster">
    <?php foreach ($blocks as $block): ?>
        <?php if ($block['id_widget'] > 0): ?>
            <li data-row="<?php echo $block['row'] ?>"
                data-col="<?php echo $block['col'] ?>"
                data-sizex="<?php echo $block['size_x'] ?>"
                data-sizey="<?php echo $block['size_y'] ?>"
                data-id_widget="<?php echo $block['id_widget'] ?>"
                data-widget="<?php echo $block['widget']['name'] ?>"
                style="<?php echo $block['widget']['style'] ?>">
                <div class="content">
                    <?php echo $this->element(
                        'view',
                        array('widget' => $block['widget']),
                        array('plugin' => ucfirst($block['widget']['name']) . 'Widget'));
                    ?>
                </div> 
				<?php if ($this->Session->read('user.is_admin')): ?>
                <div class="widget-handle">
                    <?php echo $this->Html->link('edit', array(
                            'controller' => 'AdminWidgets',
                            'action' => 'edit'),
                        array('class' => 'edit'))?>
                    <?php echo $this->Html->link('delete', array(
                            'controller' => 'AdminWidgets',
                            'action' => 'delete'),
                        array('class' => 'delete'), 'Are you sure ?')?>
                </div>
				<?php endif; ?>
            </li>
        <?php endif; ?>
    <?php endforeach; ?>

    <?php if ($this->Session->read('user.is_admin')): ?>
        <li class="add" data-row="1" data-col="1" data-sizex="1" data-sizey="1" data-id_widget="0">
            <div class="content">
            <?php echo $this->Html->link('+', array(
                'controller' => 'adminWidgets',
                'action' => 'listTypes'));
            ?>
            </div>
            <div class="widget-handle">
                <?php echo $this->Html->link('edit', array(
                        'controller' => 'AdminWidgets',
                        'action' => 'edit'),
                    array('class' => 'edit'))?>
                <?php echo $this->Html->link('delete', array(
                        'controller' => 'AdminWidgets',
                        'action' => 'delete'),
                    array('class' => 'delete'), 'Are you sure ?')?>
            </div>
        </li>
    <?php endif; ?>
</ul>
<?php if ($this->Session->read('user.is_admin')): ?>

<?php endif; ?>